# -*- coding:utf-8 -*-

import datetime
from utils.serialization import Serialization
from app.task.common.task_sql import TaskManageSql


class TaskManageDB(object):
    def __init__(self):
        self.serialization = Serialization()
    
    def task_list(self, body):
        params = ['page','size',"session_user_id","session_company_post"]
        null_params = []
        sql = TaskManageSql.TASK_LIST
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def task_member_list(self, body):
        params = ['page','size']
        null_params = []
        sql = TaskManageSql.TASK_GROUP_LIST
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def task_info(self, body):
        params = ["page","size",'id']
        null_params = ["page","size"]
        sql = TaskManageSql.TASK_INFO
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def task_member_info(self, body):
        params = ['page','size','task_id']
        null_params = ['page','size']
        sql = TaskManageSql.TASK_GROUP_INFO
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret

    def task_leader_list(self, body):
        """可以作为领导的列表"""
        params = ["page", "size", "session_user_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.TASK_GROUP_LEADER_LIST
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def project_task_leader_list(self, body):
        """可以作为领导的列表"""
        params = ["page", "size","project_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.PROJETC_TASK_GROUP_LEADER_LIST
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret

    def task_info_person(self, body):
        # 查看自己所在的项目
        params = ["page", "size", "session_user_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.TASK_INFO_PERSON
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret

    def task_info_person_all(self, body):
        # 查看所有进行的项目
        params = ["page", "size", "session_user_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.TASK_INFO_PERSON_ALL
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret

    def task_empty_person(self, body):
        """查看没有项目的用户"""
        params = ["page", "size", "object_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.TASK_EMPTY_PERSON
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def project_task_list(self,body):
        params = ["page", "size", "object_id"]
        null_params = ["page", "size"]
        sql = TaskManageSql.PROJECT_TASK_LIST
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
    def task_search(self,body):
        params = ['page','size',"session_user_id","session_company_post","search_content"]
        null_params = ["page", "size"]
        sql = TaskManageSql.TASK_SEARCH
        ret = self.serialization.query_list(body, params, null_params, sql)
        return ret
    
